package main

import (
	"fmt"
	"io/ioutil"
	"strings"
)

const (
	basePath   = "template"
	serverPath = "template/server"
	webPath    = "template/web"
)

func main() {
	path := strings.TrimPrefix("D:\\test\\quanchengexue\\resources\\app", "D:\\test\\quanchengexue\\resources")
	fmt.Println(path)
}

// fileList,_:= GetAllTplFile(basePath,nil)
// fmt.Print(fileList,"\n")
// fileList,_= GetAllTplFile(serverPath,nil)
// fmt.Print(fileList,"\n")
// fileList,_= GetAllTplFile(webPath,nil)
// fmt.Print(fileList,"\n")
func GetAllTplFile(pathName string, fileList []string) ([]string, error) {
	files, err := ioutil.ReadDir(pathName)
	for _, fi := range files {
		if fi.IsDir() {
			fileList, err = GetAllTplFile(pathName+"/"+fi.Name(), fileList)
			if err != nil {
				return nil, err
			}
		} else {
			if strings.HasSuffix(fi.Name(), ".tpl") {
				fileList = append(fileList, pathName+"/"+fi.Name())
			}
		}
	}
	return fileList, err
}
